<?php
/**
 * Created By virus_cms
 * Author: Virus
 * Date: 2020/2/28
 * Time: 23:14
 */

declare(strict_types=1);

namespace app\common\lib;


class Str
{
    /**
     * 根据长度生成随机字符串
     * @param int $len
     * @return string
     */
    public static function setRandStr(int $len): string
    {
        $str    = null;
        $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
        $max    = strlen($strPol) - 1;

        for ($i = 0; $i < $len; $i++) {
            $str .= $strPol[rand(0, $max)];
        }

        return $str;
    }
}